import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();

/**
 * 公共数据插入
 * @param data 插入数据
 * @param tableName 表名
 * @returns {Promise<*>}
 */
export const createData = async (data,tableName) => {
    try {
        const res = await prisma[tableName].create({
            data,
        });
        console.log('数据插入成功',res.id);
        return res
    } catch (error) {
        console.log('数据插入失败',error.message);
        throw error.message;
    } finally {
        await prisma.$disconnect();
    }
};
